package com.tianyalei.wolf.sample.activity.banner;

import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;

import com.tianyalei.wolf.mddesignlib.utils.ToastUtil;
import com.tianyalei.wolf.sample.R;
import com.tianyalei.wolf.sample.activity.base.BaseToolBarActivity;
import com.tianyalei.wolf.sample.imageload.ImageLoadProxy;

import java.util.ArrayList;

import butterknife.Bind;
import butterknife.ButterKnife;

public class BannerActivity extends BaseToolBarActivity {

    @Bind(R.id.indicator_default_circle)
    ImageCycleView indicatorDefaultCircle;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ButterKnife.bind(this);

        initData();
    }

    @Override
    protected int getLayoutResource() {
        return R.layout.activity_banner;
    }

    private void initData() {
        /**装在数据的集合  文字描述*/
        ArrayList<String> imageDescList = new ArrayList<>();
        /**装在数据的集合  图片地址*/
        ArrayList<String> urlList = new ArrayList<>();
        /**添加数据*/
        urlList.add("http://attach.bbs.miui.com/forum/month_1012/101203122706c89249c8f58fcc.jpg");
        urlList.add("http://bbsdown10.cnmo.com/attachments/201308/06/091441rn5ww131m0gj55r0.jpg");
        urlList.add("http://attach.bbs.miui.com/forum/201604/05/001754vp6j0vmcj49f0evc.jpg.thumb.jpg");
        urlList.add("http://d.3987.com/taiqiumein_141001/007.jpg");
        urlList.add("http://attach.bbs.miui.com/forum/201604/05/100838d2b99k6ihk32a36a.jpg.thumb.jpg");
        imageDescList.add("小仓柚子");
        imageDescList.add("抚媚妖娆性感美女");
        imageDescList.add("热血沸腾 比基尼");
        imageDescList.add(" 台球美女");
        imageDescList.add("身材妙曼");
        initCarsuelView(imageDescList, urlList);
    }

    /**
     * 初始化轮播图的关键方法
     */
    public void initCarsuelView(ArrayList<String> imageDescList, final ArrayList<String> urlList) {
        ImageCycleView.ImageCycleViewListener mAdCycleViewListener = new ImageCycleView.ImageCycleViewListener() {
            @Override
            public void onImageClick(int position, View imageView) {
                /**实现点击事件*/
                ToastUtil.showToast(BannerActivity.this, urlList.get(position));
            }

            @Override
            public void displayImage(String imageURL, ImageView imageView) {
                /**在此方法中，显示图片，可以用自己的图片加载库，也可以用本demo中的（Imageloader）*/
                ImageLoadProxy.displayNormalImage(BannerActivity.this, imageURL, imageView);
            }
        };
        /**设置数据*/
        indicatorDefaultCircle.setImageResources(imageDescList, urlList, mAdCycleViewListener);
        indicatorDefaultCircle.startImageCycle();
    }

}
